import request from "@/utils/request";

/**
 * 施工计划列表
 */
export const constructionPlan = customerId => {
  return request({
    url: `/crm/info/buildplanList/${customerId}`,
    method: "get"
  });
};

/**
 * 开启施工阶段或停工
 * @param {string} customerId
 * @param {boolean} buildEnable
 */
export const startStage = customerId => {
  return request({
    url: `/crm/info/startBuildStage/${customerId}/true`,
    method: "get"
  });
};

/**
 * 关闭施工阶段
 */
export const stopStage = customerId => {
  return request({
    url: `/crm/info/returnCustomerStage/${customerId}`,
    method: "get"
  });
};

/**
 * 获取调整后的时间
 * @param {string} stageTaskId
 * @param {adjustTimeParans} params
 */
export const adjustTime = (params, stageTaskId) => {
  return request({
    url: `/crm/task/adjust/getChangeTime/${stageTaskId}`,
    method: "get",
    params
  });
};

/**
 * 提交计划调整时间
 * @param {string} stageTaskId
 * @param {submitAdjustParams} data
 */
// export const submitAdjustTime = (stageTaskId, data) => {
//   return request({
//     url: `/crm/task/adjust/apply/${stageTaskId}`,
//     method: "post",
//     data
//   });
// };

/**
 * 提交计划调整时间 - 无权限限制
 * @param {string} stageTaskId
 * @param {submitAdjustParams} data
 */
export const submitAdminAdjustTime = (stageTaskId, data) => {
  return request({
    url: `/crm/task/adjust/applyAdmin/${stageTaskId}`,
    method: "post",
    data
  });
};

/**
 * 任务模板列表
 * @param {object} params
 * @param {string} params.packageName
 */
export const templateTaskList = params => {
  return request({
    url: "/crm/task/template/list",
    method: "get",
    params
  });
};

/**
 * 发起任务
 */
export const publishTask = (customerId, packageId) => {
  return request({
    url: `/crm/build/task/startTaskTemplate/${customerId}/${packageId}`,
    method: "post"
  });
};

/**
 * 任务阶段+状态信息
 */
export const stageList = customerId => {
  return request({
    url: `/crm/build/plan/buildplanHeadList/${customerId}`,
    method: "get"
  });
};
/**
 *筛选负责人
 */
export const directorList = params => {
  return request({
    url: `/crm/build/plan/selectionManager`,
    method: "get",
    params
  });
};
/**
 *筛选任务名称
 */
export const taskNameList = params => {
  return request({
    url: `/crm/build/plan/selectionTaskName`,
    method: "get",
    params
  });
};
/**
 * 施工计划列表
 * @param customerId  客户id
 * @param params  搜索条件
 * @returns {*}
 */
export const planList = (customerId, params) => {
  return request({
    url: `/crm/build/plan/buildplanList/${customerId}`,
    method: "get",
    params
  });
};
/**
 * 开工确认
 * data:提交参数
 */
export const startWorkConfirm = data => {
  return request({
    url: `/crm/build/start/confirm`,
    method: "post",
    data
  });
};

/**
 * 开工停工
 */
export const operateWork = data => {
  return request({
    url: `/crm/build/operate`,
    method: "post",
    data
  });
};
/**
 * 调整计划详情
 * stageTaskId 任务id
 */
export const adjustPlanDetail = stageTaskId => {
  return request({
    url: `/crm/build/plan/getAdjustTaskPlan/${stageTaskId}`,
    method: "get"
  });
};
/**
 * 获取调整后的时间
 */
export const changeTime = (stageTaskId, params) => {
  return request({
    url: `/crm/build/plan/getBuildChangeTime/${stageTaskId}`,
    method: "get",
    params
  });
};
/**
 *提交调整时间
 */
export const submitAdjustTime = data => {
  return request({
    url: `/crm/build/plan/addAdjustTaskPlan`,
    method: "post",
    data
  });
};
/**
 *提交调整时间
 */
export const taskSubmitAdjustTime = data => {
  return request({
    url: `/crm/build/plan/addAdminAdjustTaskPlan`,
    method: "post",
    data
  });
};
/**
 * 根据角色id筛选人员
 */

export const memberByRoleId = params => {
  return request({
    url: `/crm/build/plan/selectionRoleIdUserName`,
    method: "get",
    params
  });
};

/**
 *开工确认详情信息
 */

export const workConfirmDetail = customerId => {
  return request({
    url: `/crm/build/start/${customerId}`,
    method: "get"
  });
};
/**
 * 历史调整记录列表
 */
export const adjustHistoryList = customerId => {
  return request({
    url: `/crm/build/plan/customerDelayList/${customerId}`,
    method: "get"
  });
};
/**
 * 客户延期单提交
 */
export const submitDelay = data => {
  return request({
    url: `/crm/build/plan/openCustomerDelay`,
    method: "post",
    data
  });
};
/**
 *历史延期单列表
 */
export const delayList = customerId => {
  return request({
    url: `/crm/build/plan/getDelayList/${customerId}`,
    method: "get"
  });
};
/**
 * 完工日期
 */
export const completionDate = (customerId, params) => {
  return request({
    url: `/crm/build/getContractPlainEndDate/${customerId}`,
    method: "get",
    params
  });
};

/**
 * 开启施工阶段和返回营销阶段
 */
export const startStageAndReturn = (customerId, buildEnable) => {
  return request({
    url: `/crm/build/plan/startBuildStage/${customerId}/${buildEnable}`,
    method: "get"
  });
};
